function changeSrcolColor(css) {
	if (css == 'ext-all.css') {
		document.body.style.scrollbarBaseColor = "#bdd3ef";
	} else if (css == 'xtheme-gray.css') {
		document.body.style.scrollbarBaseColor = "#dcdcdc";
	} else if (css == 'xtheme-slate.css') {
		document.body.style.scrollbarBaseColor = "#647890";
	} else if (css == 'xtheme-black.css') {
		document.body.style.scrollbarBaseColor = "#2d2d2d";
	} else if (css == 'xtheme-olive.css') {
		document.body.style.scrollbarBaseColor = "#add684";
	} else if (css == 'xtheme-purple.css') {
		document.body.style.scrollbarBaseColor = "#bca7ff";
	}
}

Ext.ux.ThemeCycleButton = Ext.extend(Ext.CycleButton, {

	/**
	 * 
	 * file 你的css名称
	 * 
	 * text 下拉框的名称
	 * 
	 * iconCls 设置图标css
	 * 
	 */

	cssItems : [

	{
				file : 'ext-all.css',
				text : '蓝色月影 ',
				checked : true,
				iconCls : 'icon-blue-theme'
			},

			{
				file : 'xtheme-gray.css',
				text : '灰色回忆 ',
				iconCls : 'icon-gray-theme'
			},

			{
				file : 'xtheme-slate.css',
				text : '深蓝心情 ',
				iconCls : 'icon-slate-theme'
			},

			{
				file : 'xtheme-black.css',
				text : '黑色物语 ',
				iconCls : 'icon-blue-theme'
			},

			{
				file : 'xtheme-olive.css',
				text : '绿色芳香 ',
				iconCls : 'icon-olive-theme'
			},

			{
				file : 'xtheme-purple.css',
				text : '诱惑紫色 ',
				iconCls : 'icon-blue-theme'
			}

	],

	themeVar : 'style',

	headVar : 'head',

	// cssPath是你放css的位置，这个路径要是弄错了，神仙也出不来的

	cssPath : 'resources/css/',

	initComponent : function() {

		Ext.apply(this, {

					showText : true,

					prependText : ' ',

					items : this.cssItems

				});

		if (Ext.state.Manager) {

			var selectedTheme = Ext.state.Manager.get(this.themeVar);

			if (selectedTheme) {

				for (var i = 0; i < this.items.length; i++) {

					if (this.items[i].file == selectedTheme) {

						this.items[i].checked = true;

						// this.setActiveItem(this.items[i], true); //error ??

						this.changeHandler(this, this.items[i]);

						// this.changeHandler.defer(1000, this, [this,
						// this.items[i]]);

						break;

					}

				}

			}

		}

		Ext.ux.ThemeCycleButton.superclass.initComponent.apply(this, arguments);

	},

	changeHandler : function(o, i) {
		changeSrcolColor(i.file);
//定义两个全局变量
		skino = o;
		skini = i;

			var a = window.frames;
			for (var j = 0; j < a.length; j++) {
				if(a[j].name=='tabiframe'){
				a[j].changeskin(o, i);
				}

			}


		if (Ext.state.Manager.getProvider()) {
			Ext.state.Manager.set(this.themeVar, i.file);
			Ext.state.Manager.set(this.headVar, i.head);
		}

		Ext.util.CSS.swapStyleSheet(this.themeVar, this.cssPath + i.file);

		Ext.util.CSS.getRule('.x-panel-body', true).style.background = 'url('
				+ i.head + ')';

		// Ext.util.CSS.updateRule('.x-panel-body', 'background', 'url(' +
		// i.head + ')');

		if (Ext.getCmp('viewport')) {

			Ext.getCmp('viewport').layout.center.panel.setSize(Ext
					.getCmp('viewport').layout.center.getSize().width
					+ 1);

			Ext.getCmp('viewport').doLayout();

			Ext.getCmp('viewport').layout.center.panel.setSize(Ext
					.getCmp('viewport').layout.center.getSize().width
					- 1);

			Ext.getCmp('viewport').doLayout();

		}

	}

});

Ext.reg('themecyclebutton', Ext.ux.ThemeCycleButton);